<?php



namespace App\Http\Requests\Company;

use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class QuestionRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:120',

        ];
    }

    public function messages()
    {
        return [
            'title.required' => __('请输入考题的标题'),
            'my_category_id.required' => __('请输入考题的分类'),

        ];
    }

    public function filldata()
    {

        $user = Auth::user();
        return [
            'user_id'=>(int)$user['app_id'],
            'my_category_id'=>(int)$this->input('my_category_id',0),
            'company_id' =>(int)$user['login_company_id'],
            'title' =>(string) $this->input('title', ''),
            'star' =>(string) $this->input('star', 1),
            'content' => (string)$this->input('content', ''),
            'analysis'=>(string)$this->input('analysis',''),
            'difficulty'=>(string)$this->input('difficulty',''),
            'type'=>(int)$this->input('type',1),
            'answer_label'=>(string)$this->input('answer_label',''),
            'answers'=>(array)$this->input('answers',[]),
            'video_ids'=>(array)$this->input('video_ids'),
            'file_ids'=>(array)$this->input('file_ids'),
            'tags'=>(array)$this->input('tags'),
            'recommends' => $this->input('recommends',[]),
            'is_free'=>$this->input('is_free',1)

        ];
    }
}
